
    #################################################################
    #################################################################
    #
    #     This file replicates:
    #        Figure 1, Figure 2, Figure 4, Figure A1, and Figure A2
    # 
    #################################################################
    #################################################################

    ### Required Adjustments  
    setwd("C:\\temp1")  # Set your working directory. All data and bugs files should be stored in this directory. 

    # aggregate data   
    House_Data <- read.csv("House_Figures_Data.csv", header=T)
    Senate_Data <- read.csv("Senate_Figures_Data.csv", header=T)
    Macro_Data <- read.csv("Macro_Data.csv", header=T)
    
    # Micro-level data 
    House_Micro_Data <- read.csv("House_Micro_Data.csv", header=T)
    Senate_Micro_Data <- read.csv("Senate_Micro_Data.csv", header=T)

    n.Congress <- length(unique(House_Data$congress))
    T1 <- min(unique(House_Data$congress))
    T2 <- max(unique(House_Data$congress))
    Congress <- T1:T2
    T <- length(T1:T2)
    Years <- seq(from=1971, to=2015, by=2)

    # Replication Figure 1
    
    pdf("Figure1.pdf", height=11, width=9)
    par(mfrow=c(3, 1))
    plot(1:n.Congress, House_Data$antidefense_number, type='n', col='black', lty=3, ylim=c(0,70), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, House_Data$prodefense_number,  type='o', lty=2, col='red')
    points(1:n.Congress, House_Data$antidefense_number,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spedning Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Frequency", font.main=1)
    plot(1:n.Congress, House_Data$prodefense_success, type='o', col='red', lty=2, ylim=c(0,1), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, House_Data$antidefense_success,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topright', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spending Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Passage Rate", font.main=1)
    plot(1:n.Congress, House_Data$prodefense_sponsor, type='o', col='red', lty=2, ylim=c(-5,5), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, House_Data$antidefense_sponsor,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spending Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Average Hawkishness of Sponsors", font.main=1)
    dev.off()

    # Replicate Figure 2

    pdf("Figure2.pdf", height=11, width=9)
    par(mfrow=c(3, 1))
    plot(1:n.Congress, Senate_Data$antidefense_number, type='n', col='black', lty=3, ylim=c(0,70), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, Senate_Data$prodefense_number,  type='o', lty=2, col='red')
    points(1:n.Congress, Senate_Data$antidefense_number,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spedning Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Frequency", font.main=1)
    plot(1:n.Congress, Senate_Data$prodefense_success, type='o', col='red', lty=2, ylim=c(0,1), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, Senate_Data$antidefense_success,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topright', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spending Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Passage Rate", font.main=1)
    plot(1:n.Congress, Senate_Data$prodefense_sponsor, type='o', col='red', lty=2, ylim=c(-5,5), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, Senate_Data$antidefense_sponsor,  type='o', lty=1, col='blue')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Pro-Defense Spending Amendments", "Anti-Defense Spending Amendments"), lty=c(2,1), col=c('red','blue'), cex=.8)
    title(main="Average Hawkishness of Sponsors", font.main=1)
    dev.off()

 
    # Replicate Figure 4

    pdf("Figure4.pdf", height=10, width=10)
    par(mfrow=c(2, 1))
    plot(1:T, 1:T, type='n', col='blue', cex=.7, ylim=c(-3,3), xaxt="n", xlab="",ylab="")
    axis(side=1, las=3, at=1:T, labels=Years, cex.axis=.8)
    points(1:T, Macro_Data$Dem.median[1:T], type='o', lty=2, col='blue')
    points(1:T, Macro_Data$Rep.median[1:T], type='o', lty=2, col='red')
    points(1:T, Macro_Data$Dem.leaders.median[1:T], type='o', lty=1, col='blue')
    points(1:T, Macro_Data$Rep.leaders.median[1:T], type='o', lty=1, col='red')
    title(main="Senate", font.main=1)
    legend('topleft', legend=c("Dem leaders", "GOP leaders", "Dem caucus", "GOP conference"), 
            lty=c(1,1, 2, 2), col=c('blue','red','blue','red'),cex=.8)
    plot(1:T, 1:T, type='n', col='blue', cex=.7, ylim=c(-3, 3), xaxt="n", xlab="",ylab="")
    axis(side=1, las=3, at=1:T, labels=Years, cex.axis=.8)
    points(1:T, Macro_Data$Dem_House.median, type='o', lty=2, col='blue')
    points(1:T, Macro_Data$Rep_House.median, type='o', lty=2, col='red')
    points(1:T, Macro_Data$Dem_House.leaders.median, type='o', lty=1, col='blue')
    points(1:T, Macro_Data$Rep_House.leaders.median, type='o', lty=1, col='red')
    title(main="House", font.main=1)
    legend('topleft', legend=c("Dem leaders", "GOP leaders", "Dem caucus", "GOP conference"), 
            lty=c(1,1, 2, 2), col=c('blue','red','blue','red'),cex=.8)
    dev.off()
    

    # Replicate Figure A1

    pdf("Figure_A1.pdf", height=10, width=9)
    par(mfrow=c(2, 1))
    plot(1:n.Congress, Senate_Data$total_riders, type='n', col='black', lty=1, ylim=c(0,30), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, Senate_Data$rider_A,  type='o', pch=1, lty=2, col='blue')
    points(1:n.Congress, Senate_Data$rider_B,  type='o', pch=2, lty=3, col='red')
    points(1:n.Congress, Senate_Data$rider_C,  type='o', pch=3, lty=4, col='purple')
    points(1:n.Congress, Senate_Data$rider_D,  type='o', pch=4, lty=5, col='green')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Funding reduction in specific programs", "Attach conditions", "Prohibit spendings on certain programs", "Funding reduction in overall defense spending"), pch=c(1,2,3,4), lty=c(2,3,4,5), col=c('blue','red','purple','green'), cex=.8)
    title(main="Senate", font.main=1)
    plot(1:n.Congress, House_Data$total_riders, type='n', col='black', lty=1, ylim=c(0,30), xaxt="n", xlab="",ylab="")
    points(1:n.Congress, House_Data$rider_A,  type='o', pch=1, lty=2, col='blue')
    points(1:n.Congress, House_Data$rider_B,  type='o', pch=2, lty=3, col='red')
    points(1:n.Congress, House_Data$rider_C,  type='o', pch=3, lty=4, col='purple')
    points(1:n.Congress, House_Data$rider_D,  type='o', pch=4, lty=5, col='green')
    axis(side=1, las=3, at=seq(from=1, to=n.Congress, by=1), labels=Years, cex.axis=.8)
    legend('topleft', legend=c("Funding reduction in specific programs", "Attach conditions", "Prohibit spendings on certain programs", "Funding reduction in overall defense spending"), pch=c(1,2,3,4), lty=c(2,3,4,5), col=c('blue','red','purple','green'), cex=.8)
    title(main="House", font.main=1)
    dev.off()


    # Replicate Figure A2
    
    Y_hawk  <- House_Micro_Data$Yea_share[House_Micro_Data$dovish_riders == 0]  
    Y_dove  <- House_Micro_Data$Yea_share[House_Micro_Data$dovish_riders == 1]  

    Sen_hawk  <- Senate_Micro_Data$Yea_share[Senate_Micro_Data$dovish_riders == 0]  
    Sen_dove  <- Senate_Micro_Data$Yea_share[Senate_Micro_Data$dovish_riders == 1]  
    

    pdf("Figure_A2.pdf", height=12, width=10)
    par(mfrow=c(2,2))
    par(mar=c(4, 5, 4, 3))
    hist(Y_hawk, breaks=20, main="", xlab="Voteshare(%)", xlim=c(0, 100))
    title(main="Non-Dovish Amendments (House)", font.main=1)
    hist(Sen_hawk, breaks=20, main="", xlab="Voteshare(%)", xlim=c(0, 100))
    title(main="Non-Dovish Amendments (Senate)", font.main=1)
    hist(Y_dove, breaks=20, main="", xlab="Voteshare(%)", xlim=c(0, 100))
    title(main="Dovish Amendments (House)", font.main=1)
    hist(Sen_dove, breaks=20, main="", xlab="Voteshare(%)", xlim=c(0, 100))
    title(main="Dovish Amendments (Senate)", font.main=1)
    dev.off()

